package modelLayer;

import java.util.ArrayList;

public class FlavourContainer {
	private static FlavourContainer instance;
	private ArrayList<Flavour> flavours;
	
	private FlavourContainer(){
		flavours = new ArrayList<Flavour>();
	}
	
	public static FlavourContainer getInstance(){
		if(instance == null){
			instance = new FlavourContainer();
		}
		return instance;
	}
	
	public void addFlavour(Flavour f){
		flavours.add(f);
	}
	
	public Flavour getFlavour(String flavourName){
		Flavour ret = null;
		for(Flavour f : flavours){
			if(f.getFlavour().equalsIgnoreCase(flavourName)){
				ret = f;
				break;
			}
		}
		return ret;
	}
	
	public Flavour getFlavour(int id){
		Flavour ret = null;
		for(Flavour f : flavours){
			if(f.getId() == id){
				ret = f;
				break;
			}
		}
		return ret;
	}
	
	public ArrayList<Flavour> getAll(){
		return flavours;
	}
}
